﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Personalization.aspx.cs" Inherits="Sites_sodc_vie_Personalization" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        string Site = "{Site}";
        string Alias = Request["{Alias}"];
        AjaxPro.Utility.RegisterTypeForAjax(typeof(Portal.Environment.Environments));
        AjaxPro.Utility.RegisterTypeForAjax(typeof(Portal.Environment.PersonalizationBll));
        string HtmlText = Portal.Environment.PersonalizationBll.GetPersonalizationConfigModuleForUser(Site, Alias);
        placeHolderContent.Controls.Clear();
        placeHolderContent.Controls.Add(new System.Web.UI.LiteralControl(HtmlText));
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <style>
        .cssTdZoneTitlePersonalization
        {
            color:Maroon;
            font-size:18px;
            font-weight:bold;
            background-color:whitesmoke;
            padding:3px;
        }

        .cssDivPersonalizationTab
        {
            padding:4px;
            background-color:whitesmoke;
            border:solid 1px gray;
            margin-left:50px;
            margin-top:50px;
            width:700px;
        }
        
        .cssTdTitlePersonalization
        {
            padding-left:50px;
        }
        
        .cssSelectActivePersonalization
        {
            width:110px;
        }
        
        .cssSelectZonePersonalization
        {
            width:160px;
        }
        
        .cssTdTitlePersonalization
        {
            width:200px;
            text-align:right;
            padding-right:5px;
        }
        
        .cssDivPersonalizationTabTitle
        {
            padding-left:2px;
            padding-top:4px;
            height:30px;
            font-weight:bold;
            background-color:Blue;
            color:White;
        }
        
        .cssTextBoxPositionPersonalization
        {
            width:30px;
            text-align:right;
            border:solid 1px gray;
            background-color:Yellow;
        }
    </style>
</head>
<body>
    <script type="text/javascript">
        function ClientSaveItem(PersonalizationTabModuleId) {
            DestZoneIndex = document.getElementById("drpMoveZone" + PersonalizationTabModuleId).selectedIndex;
            DestZone = document.getElementById("drpMoveZone" + PersonalizationTabModuleId).options[DestZoneIndex].value;

            ActiveIndex = document.getElementById("drpSelectActive" + PersonalizationTabModuleId).selectedIndex;
            Active = document.getElementById("drpSelectActive" + PersonalizationTabModuleId).options[ActiveIndex].value;
            Position = document.getElementById("txtPosition" + PersonalizationTabModuleId).value;
            ErrMsg = Portal.Environment.PersonalizationBll.SavePersonalizationConfigModuleForUser(PersonalizationTabModuleId, DestZone, Active, Position).value;
            alert(ErrMsg);
        }

        function ClientResetToDefault(BelongSite, Alias, LoginName) {
            if (confirm('Bạn đã chắc chắn chưa?') == false) return;
            ErrMsg = Portal.Environment.PersonalizationBll.ResetPersonalizationConfigModuleForUserToDefault(BelongSite, Alias, LoginName).value;
            alert(ErrMsg);
            if (ErrMsg.indexOf("ERROR") == -1) {
                window.open("Personalization.aspx?Alias=" + Alias, '_self');
            }
        }

        function RealClientSavePersonalization() {
            Ids = document.getElementById("txtIds").value;
            PersonalizationItems = Portal.Environment.PersonalizationBll.GetPersonalizationItems(Ids).value;
            for (var Index = 0; Index < PersonalizationItems.length; Index++) {
                PersonalizationTabModuleId = PersonalizationItems[Index].PersonalizationTabModuleId;
                DestZoneIndex = document.getElementById("drpMoveZone" + PersonalizationTabModuleId).selectedIndex;
                DestZone = document.getElementById("drpMoveZone" + PersonalizationTabModuleId).options[DestZoneIndex].value;

                ActiveIndex = document.getElementById("drpSelectActive" + PersonalizationTabModuleId).selectedIndex;
                Active = document.getElementById("drpSelectActive" + PersonalizationTabModuleId).options[ActiveIndex].value;
                Position = document.getElementById("txtPosition" + PersonalizationTabModuleId).value;


                PersonalizationItems[Index].DestZone = DestZone;
                PersonalizationItems[Index].Active = Active.toString();
                PersonalizationItems[Index].Position = Position.toString();
            }
            document.getElementById("divProcessing").innerHTML = "";
            ErrMsg = Portal.Environment.PersonalizationBll.SavePersonalizationTab(PersonalizationItems).value;
            alert(ErrMsg);
        }
    </script>
    <form id="frmPersonalization" runat="server">
    <div>
        <asp:PlaceHolder ID="placeHolderContent" runat="server"></asp:PlaceHolder>
    </div>
    </form>
</body>
</html>
